﻿using Entity.Finance.DTO.IncomeAccount;
using Entity.Finance.DTO.PayManage;
using Entity.Finance.View.PayManage;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service;
using Service.System;

namespace AnQinManagermentBackendAPI.Controller.Finance
{
    /// <summary>
    /// 对账单
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    [AllowAnonymous]
    public class PayManagesController : ControllerBase
    {
        /**
         * 业务接口
         */
        private readonly PayManageService _service;

        /**
         * 构造函数注入
         */
        public PayManagesController(PayManageService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        [ProducesResponseType(typeof(PayManageView), 200)]
        public async Task<IActionResult> GetPayManageList([FromQuery] PayManageSearchDTO model)
        {
            var response = await _service.GetPayManageList(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 付款
        /// </summary>
        [HttpPost("Pay")]
        public async Task<IActionResult> Pay([FromBody] PayManagePayDto model)
        {
            var response = await _service.Pay(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 退款
        /// </summary>
        [HttpPost("Return")]
        public async Task<IActionResult> Return([FromBody] PayManagePayDto model)
        {
            var response = await _service.Return(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeletePayManage([FromQuery] string Id)
        {
            var response = await _service.DeletePayManage(Id);
            return StatusCode(response.Status, response);
        }

    }
}
